import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 预警配置信息 */
export interface WarningConfig {
          id: number; // id
          warningDays?: number; // 预警(天数)
          warningLevel?: number; // 预警等级
          warningColor: string; // 预警颜色
  }

// 预警配置 API
export const WarningConfigApi = {
  // 查询预警配置分页
  getWarningConfigPage: async (params: any) => {
    return await request.get({ url: `/business/warning-config/page`, params })
  },

  // 查询预警配置详情
  getWarningConfig: async (id: number) => {
    return await request.get({ url: `/business/warning-config/get?id=` + id })
  },

  // 新增预警配置
  createWarningConfig: async (data: WarningConfig) => {
    return await request.post({ url: `/business/warning-config/create`, data })
  },

  // 修改预警配置
  updateWarningConfig: async (data: WarningConfig) => {
    return await request.put({ url: `/business/warning-config/update`, data })
  },

  // 删除预警配置
  deleteWarningConfig: async (id: number) => {
    return await request.delete({ url: `/business/warning-config/delete?id=` + id })
  },

  /** 批量删除预警配置 */
  deleteWarningConfigList: async (ids: number[]) => {
    return await request.delete({ url: `/business/warning-config/delete-list?ids=${ids.join(',')}` })
  },

  // 导出预警配置 Excel
  exportWarningConfig: async (params) => {
    return await request.download({ url: `/business/warning-config/export-excel`, params })
  }
}